package com.lovetemperature.service.impl;

import java.util.List;

import com.lovetemperature.dao.Dao;
import com.lovetemperature.model.Member;
import com.lovetemperature.model.Staff;
import com.lovetemperature.service.StaffService;

public class StaffServiceImpl implements StaffService {
	private Dao<Staff> staffDao;
	
	@Override
	public Staff login(String account, String password) {
		List<Staff> result = staffDao.findByField("account", account);
		if (result == null || result.size() == 0) {
			return null;
		} else if (result.get(0).getPassword().endsWith(password)) {
			return result.get(0);
		}
		return null;
	}

	public Dao<Staff> getStaffDao() {
		return staffDao;
	}

	public void setStaffDao(Dao<Staff> staffDao) {
		this.staffDao = staffDao;
	}

	@Override
	public void update(Staff staff) {
		staffDao.update(staff);
	}

	@Override
	public List<Staff> findAllStaff() {
		return staffDao.findAll();
	}

	@Override
	public Staff findById(Long staffId) {
		return staffDao.findById(staffId);
	}

	@Override
	public void addStaff(Staff staff) {
		staffDao.save(staff);
	}
}
